//===============================
//  功能 ：备注 
//  作者 ：上中野辅亚瑟王 
//  创建时间 ：2023-06-12  10-58-18 
//  Unity版本  ：2019.4.35f1 
//  变更时间 :  2023-06-12  10-58-18 
//===============================





//using System.Collections;
//using System.Collections.Generic;
//using UniFramework.Animation;
//using UnityEngine;
//using ZS.U3D.BASE.Networking;
//using ZS.U3D.BASE.Runtime.Singleton;
//using ZS.U3D.BASE.Runtime.StateMachine;
//using ZS.U3D.BASE.Runtime.Utils;

//public class PlayerController : MonoBehaviour
//{

//    public string id;


//    private void Start()
//    {
//        SingletonManager.Initialize();
//        gameObject.AddComponent<PlayerStateController>();
//    }

//}


//public class PlayerStateController :MonoBehaviour
//{
//    public abstract class PlayerStateNode : IStateNode
//    {

//        internal StateMachine stateMachine;
//        internal AnimationController animationController;


//        public virtual void OnCreate(StateMachine machine, params object[] ps)
//        {
//            stateMachine = machine;
//            animationController = ps[0] as AnimationController;
//        }

//        public virtual void OnStart() {

//        }

//        public virtual void OnUpdate()
//        {

//        }

//        public virtual void OnEnd() 
//        {

//        }
//    }

//    public class Idel : PlayerStateNode
//    {
//        public override void OnStart()
//        {
//            base.OnStart();
//            Debug.Log("Idel OnStart");
//            animationController.Play("待机站立10-150");

//        }
//    }

//    public class Walk : PlayerStateNode
//    {
//        public override void OnStart()
//        {
//            base.OnStart();
//            animationController.Play("原地走路0-8");
//        }
//    }

//    public class 收集道具 : PlayerStateNode {
//        public override void OnStart()
//        {
//            base.OnStart();
//            animationController.Play("收集道具 480-505");
//        }
//    }



//    [SerializeField]
//    private AnimationController animationController;

//    private StateMachine playerStateMachine;

//    private PlayerController playerController;

//    private void Awake()
//    {
//        animationController = GetComponentInChildren<AnimationController>();
//        playerStateMachine = new StateMachine($"{typeof(PlayerStateController)}");

//        playerController = GetComponent<PlayerController>();

//        playerStateMachine.AddNode<Idel>(animationController);
//        playerStateMachine.AddNode<Walk>(animationController);
//        playerStateMachine.AddNode<收集道具>(animationController);

//        NetManager.AddMsgListener(typeof(Player.ChangeState), ChangeStateHandle);

        
//    }


//    private void ChangeStateHandle(DefaultNetPackage package) {
//        Player.ChangeState changeState = IMessage.FromPackage<Player.ChangeState>(package);
//        if (playerController.id==changeState.id)
//        {
//            switch (changeState.PlayerState)
//            {
//                case Player.PlayerState.Idel:
//                    playerStateMachine.Run<Idel>();
//                    break;
//                case Player.PlayerState.Walk:
//                    playerStateMachine.Run<Walk>();
//                    break;
//                case Player.PlayerState.Collect:
//                    playerStateMachine.Run<收集道具>();
//                    break;
//            }
//        }
//    }



//    private void Start()
//    {
//        Player.ChangeState changeState = new Player.ChangeState();
//        changeState.PlayerState = Player.PlayerState.Idel;
//        NetManager.SendPackage(changeState.ToPackage());
//    }

//    private void Update()
//    {
//        if (Input.GetKeyDown(KeyCode.A))
//        {
//            Player.ChangeState changeState = new Player.ChangeState();

//            changeState.PlayerState = Player.PlayerState.Walk;

//            NetManager.SendPackage(changeState.ToPackage());
//        }

//        if (Input.GetKeyDown(KeyCode.B))
//        {
//            Player.ChangeState changeState = new Player.ChangeState();

//            changeState.PlayerState = Player.PlayerState.Idel;

//            NetManager.SendPackage(changeState.ToPackage());
//        }
//    }

//}
